/**
 * 员工个税统计表
 */
app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http){
    console.log('------$scope.menuId1-----', $scope.menuId);
    console.log('------$scope.buttonArr1-----', $scope.buttonArr);

    $scope.bindBtn = function(event) {
        var datas = $scope.getSelectedRows();
        switch(event){
            case 'LAYTABLE_EXPORT_DATA':
            {
                $scope.doExport('/api/inter/tbUserPersonalTaxCount/export');
                break;
            }

            case 'event-to-del'://删除
            {
                if(datas.length == 0) {
                    layer.alert('尚未选中数据');
                } else {
                    var ids = '';
                    for(var i=0;i<datas.length;i++){
                        if(ids==''){
                            ids = datas[i].id;
                        }else {
                            ids = ids + ',' +datas[i].id;
                        }
                    }
                    layer.confirm('确定要删除吗？', {icon: 3}, function () {
                        layer.msg('处理中', {
                            icon: 16,shade: 0.01
                        });
                        $http.post('/api/inter/tbUserPersonalTaxCount/toDel', {}, {params: {ids: ids}})
                            .success(function (res) {
                                layer.close();
                                layer.msg(res.msg);
                                setTimeout(function(){
                                    location.reload();
                                }, 3000);
                            })
                            .error(function(result){
                                layer.close();
                                layer.msg("操作失败，请稍后再试！", {icon: 2});
                            });

                    }, function () {});
                }
                break;
            }

        };
    }
}


//表格双击
app.controller('dbClickCtrl', ['$scope', '$http', DbClickController]);
function DbClickController($scope, $http){
    $scope.doubleClick = function(data) {
        window.top.add_tab('员工个税统计表 - 详情','/web/base/tbUserPersonalTaxCount/toDetail?id=' + data.id);
    }
}


